{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "58504e50",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Supervised_discretion: 60 24.489795918367346 Bargained_discretion: 32 13.061224489795919 Instructed_discretion: 4 1.6326530612244898 Guided_discretion: 1 0.40816326530612246\n"
     ]
    }
   ],
   "source": [
    "## import IL Data\n",
    "import pandas as pd\n",
    "IL_delegations = pd.read_excel(\"C:\\\\Users\\\\Nir\\Dropbox\\\\Codification\\\\Law-Regulation Research\\\\Nir PhD\\\\paper 2\\\\Submission\\\\Second Submission\\\\IL_delegations.xlsx\")\n",
    "IL_delegations_dict = IL_delegations.to_dict(\"records\")\n",
    "\n",
    "num_delegations = 0\n",
    "Supervised_discretion  = 0\n",
    "Bargained_discretion = 0\n",
    "Instructed_discretion = 0\n",
    "Guided_discretion = 0\n",
    "\n",
    "#count the total number of content provisions by type\n",
    "for delegation in IL_delegations_dict:\n",
    "    num_delegations+=1\n",
    "    if delegation['del_type'] == 'mandatory' and (delegation['consent']>0 or delegation['approval']>0):\n",
    "        Supervised_discretion +=1\n",
    "    if delegation['del_type'] == 'permissive' and (delegation['consent']>0 or delegation['approval']>0):\n",
    "        Bargained_discretion +=1\n",
    "    if delegation['del_type'] == 'mandatory' and (delegation['mandatory_content']>0 or delegation['permissive_content']>0 or delegation['constraining_content']>0):\n",
    "        Instructed_discretion +=1\n",
    "    if delegation['del_type'] == 'permissive' and (delegation['mandatory_content']>0 or delegation['permissive_content']>0 or delegation['constraining_content']>0):\n",
    "        Guided_discretion +=1\n",
    "    \n",
    "print('Supervised_discretion:', Supervised_discretion, Supervised_discretion/num_delegations*100,\n",
    "      'Bargained_discretion:', Bargained_discretion, Bargained_discretion/num_delegations*100,\n",
    "      'Instructed_discretion:', Instructed_discretion, Instructed_discretion/num_delegations*100,\n",
    "      'Guided_discretion:', Guided_discretion, Guided_discretion/num_delegations*100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "85eab6f6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Supervised_discretion: 1 0.14245014245014245 Bargained_discretion: 55 7.834757834757834 Instructed_discretion: 16 2.2792022792022792 Guided_discretion: 243 34.61538461538461\n"
     ]
    }
   ],
   "source": [
    "## import UK Data\n",
    "UK_delegations = pd.read_excel(\"C:\\\\Users\\\\Nir\\\\Dropbox\\\\Codification\\\\Law-Regulation Research\\\\Nir PhD\\\\paper 2\\\\Submission\\\\Second Submission\\\\UK_delegations.xlsx\")\n",
    "UK_delegations_dict = UK_delegations.to_dict(\"records\")\n",
    "\n",
    "num_delegations = 0\n",
    "Supervised_discretion  = 0\n",
    "Bargained_discretion = 0\n",
    "Instructed_discretion = 0\n",
    "Guided_discretion = 0\n",
    "#count the total number of content provisions by type\n",
    "for delegation in UK_delegations_dict:\n",
    "    num_delegations +=1\n",
    "    if delegation['delegation_type'] == 'mandatory' and (delegation['consent']>0 or delegation['approval']>0):\n",
    "        Supervised_discretion +=1\n",
    "    if delegation['delegation_type'] == 'optional' and (delegation['consent']>0 or delegation['approval']>0):\n",
    "        Bargained_discretion +=1\n",
    "    if delegation['delegation_type'] == 'mandatory' and (delegation['mandatory_content']>0 or delegation['permissive_content']>0 or delegation['constraining_content']>0):\n",
    "        Instructed_discretion +=1\n",
    "    if delegation['delegation_type'] == 'optional' and (delegation['mandatory_content']>0 or delegation['permissive_content']>0 or delegation['constraining_content']>0):\n",
    "        Guided_discretion +=1\n",
    "    \n",
    "print('Supervised_discretion:', Supervised_discretion, Supervised_discretion/num_delegations*100,\n",
    "      'Bargained_discretion:', Bargained_discretion, Bargained_discretion/num_delegations*100,\n",
    "      'Instructed_discretion:', Instructed_discretion, Instructed_discretion/num_delegations*100,\n",
    "      'Guided_discretion:', Guided_discretion, Guided_discretion/num_delegations*100)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
